package com.duobaoyu.dby.supply.admin.controller.risk;

import com.duobaoyu.dby.channel.adapter.enums.OperationTypeEnum;
import com.duobaoyu.dby.common.core.util.R;
import com.duobaoyu.dby.supply.admin.annotation.SupplySysLog;
import com.duobaoyu.dby.supply.biz.client.resource.ResourceRiskControlAdminClient;
import com.duobaoyu.dby.supply.biz.client.resource.bean.dto.RiskStrategyConfigDTO;
import com.duobaoyu.dby.supply.biz.client.resource.bean.vo.RiskStrategyConfigInfoVO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 风险控制
 *
 * @Author chenll
 * @Date 2023/3/23
 */
@RestController
@RequestMapping("/admin/risk/control")
@RequiredArgsConstructor
public class RiskControlController {

	private final ResourceRiskControlAdminClient resourceRiskControlAdminClient;

	/**
	 * 风险策略配置查询
	 *
	 * @return
	 */
	@GetMapping("/risk/info")
	@ApiOperation(value = "风险策略配置查询", notes = "风险策略配置查询")
	@SupplySysLog(value = "风险策略配置查询", operationType = OperationTypeEnum.SELECT)
	public R<List<RiskStrategyConfigInfoVO>> getRiskStrategyInfo() {
		return R.ok(resourceRiskControlAdminClient.getRiskStrategyInfo());
	}

	/**
	 * 风险策略配置修改
	 *
	 * @param riskStrategyConfig
	 * @return
	 */
	@PostMapping("/modify")
	@ApiOperation(value = "风险策略配置修改", notes = "风险策略配置修改")
	@SupplySysLog(value = "风险策略配置修改", operationType = OperationTypeEnum.UPDATE)
	public R<Boolean> modifyRiskStrategy(@RequestBody @Valid RiskStrategyConfigDTO riskStrategyConfig) {
		return R.ok(resourceRiskControlAdminClient.modifyRiskStrategy(riskStrategyConfig));
	}
}
